Repository navigation
fix: keep swipe position on Back, reach end-of-feed retry, and six smaller fixes - #284
Merged
Merged
Conversation
In-app navigation (tapping the author) unmounted the mobile viewer without saving its place, and the remount on Back only had the feed's first cached page, so a story past it reopened at index 0 with its neighbors gone. Save the swipe snapshot when the viewer unmounts, as pagehide already does. The loading/error panel after the last story wasn't counted as a swipe target, so the gesture could never land on it and the Try Again button stayed hidden. Count it, fall back to the last panel when it goes away, and center the error on an inner box since .active sets display:block.
Two effects calling loadMore in the same commit both saw loading === false, so a mobile cold start read the ranked list several times. Guard with a ref that flips synchronously.
When the first Algolia page held only hits from other hosts, the desktop list showed "No submissions" because nothing asked for page 2 (there's no sentinel while the list is empty). loadMore now keeps paging within one call until a story lands, still capped at MAX_EMPTY_PAGES_COLD_START.
They're type='story', so the job filter misses them. New, the Ask day pages and the front-page day pages already excluded them. Show stays unfiltered, Firebase and Algolia alike, because a Show HN title that mentions hiring is a real project.
localStorage throws a SecurityError when site data is blocked, and ThemeProvider renders above the ErrorBoundary, so the whole app went blank. Fall back to the system theme and keep a chosen mode for the visit.
/newest is an in-app route but wasn't in FEED_LABELS, so links to it left for news.ycombinator.com.
Each write stores the tab's whole in-memory copy, so a stale copy erased what another tab had recorded. Drop the copies on a storage event so the next read or write starts from storage.
The inline script in index.html read localStorage unguarded. With storage blocked it threw before applying the dark class, so a dark-OS user got a light background until React's ThemeProvider caught up, plus an uncaught error. It now falls back to the OS scheme, like ThemeProvider does.
The saved position had a single slot, so opening Best (or a domain or user's submissions) replaced the Top feed's position and Back to Top lost your place. Positions are now kept per viewer, newest first, capped at 8. Opening a feed from its tab drops that feed's old position so the tab still starts at the top.
therealsama
enabled auto-merge
October 4, 2026 21:23
kplachkov
approved these changes
Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes nine bugs found in an audit of the app. Each commit is one fix with its tests, with two exceptions: the first two swipe-viewer fixes share a commit because they touch the same code, and the blocked-storage fix is split into the React provider and the inline theme script.
Mobile swipe viewer
pagehidewrites), so Back restores the way a reload does, including the scroll offset within the story.display:noneuntil activated, so a failed page left you on the last story with no way to retry. It's now a swipe target, and if it goes away while showing, the viewer falls back to the last story. The error is centered on an inner box because.activesetsdisplay:block, which overrode the panel'sflex.loadMorein the same commit both sawloading === false. A ref guard brings a mobile cold start from 5topstoriesreads to 2 against the e2e mock; desktop stays at 1.Feeds and data
loadMorenow keeps paging within one call until a story lands, still capped at 3 empty pages.type: 'story', so the job filter missed them. Show is left unfiltered on purpose, since a Show HN title that mentions hiring is a real project./newestlinks left the app. Added to the in-app link rewrite map.storageevent now drops the stale copies.localStoragethrows aSecurityErrorwhen site data is blocked, andThemeProviderrenders above theErrorBoundary. It now falls back to the system theme and keeps a chosen mode for the visit. The inline theme script inindex.htmlhad the same unguarded read: it threw an uncaught error before applying the dark class, so dark-OS users got a brief light background (about 65 ms in Chromium). It now falls back to the OS scheme too; the CSP hash is regenerated at build time.Testing
npm run typecheck,npm run lint,npm run test:run(1057 tests),npm run buildnpm run e2e: 828 passed, 40 skipped (chromium, firefox, Mobile Safari, Mobile Chrome)mobile-swipe.spec.ts).mobile-swipe.spec.ts).domain-filter.spec.ts).theme-toggle.spec.ts).SwipeStoryViewerunit tests fail without the change they cover (checked by reverting the viewer change, the fall-back-to-last-story effect, and the per-viewer snapshot change).Known limitations
/to/item/:idstill remounts the viewer, which is the secondtopstoriesread above. Avoiding it means not remounting on that rewrite, a bigger routing change.